/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package guessflags;

/**
 *
 * @author Administrator
 */

    import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import javax.swing.border.EtchedBorder;
import javax.swing.border.Border;
import javax.swing.border.BevelBorder;
import guessflags.newpackage.NewClass;
import java.util.*;



public class Cgq extends JFrame {

	private JComboBox comboBox;
	Random r=new Random();
    int x=Math.round(r.nextInt(10));
    Image img=Toolkit.getDefaultToolkit().getImage("img\\"+x+".jpg");
    Icon ico=new ImageIcon(img);
	/**
	 * Launch the application
	 * @param args
	 */



	/**
	 * Create the frame
	 */



	public Cgq() {
		super();

		final JLabel label_1 = new JLabel();
		label_1.setText("make decision");
		label_1.setBounds(191, 101, 124, 81);
		getContentPane().add(label_1);

		final JLabel lab_gq = new JLabel();
		lab_gq.setText("Flag showing");
		lab_gq.setBounds(41, 26, 85, 27);
		getContentPane().add(lab_gq);

		final JLabel lab_sf = new JLabel();
		lab_sf.setText("CHOOSE");
		lab_sf.setBounds(190, 26, 86, 27);
		getContentPane().add(lab_sf);

		final JLabel jlabel = new JLabel();
		jlabel.setBounds(10, 59, 174, 123);
		getContentPane().add(jlabel);


		getContentPane().setLayout(null);
		setBounds(100, 100, 496, 228);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


		final JButton btn_xz = new JButton();
		btn_xz.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				if(e.getSource()==btn_xz){
					int choose=comboBox.getSelectedIndex();
					if(choose==x){
						javax.swing.JOptionPane.showMessageDialog(null, "Congratulations，Correct answer！");
						ico=new ImageIcon(img);
						label_1.setIcon(ico);
					}else{
						javax.swing.JOptionPane.showMessageDialog(null, "Congratulations，Wrong answer！");
						label_1.setIcon(null);
					}

				}
			}
		});
		btn_xz.setText("SubmitAnswer");
		btn_xz.setBounds(354, 46, 124, 25);
		getContentPane().add(btn_xz);

		final JButton btn_gq = new JButton();
		btn_gq.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				if(e.getSource()==btn_gq){
				x=Math.round(r.nextInt(10));
				img=Toolkit.getDefaultToolkit().getImage("img\\"+x+".jpg");
				ico=new ImageIcon(img);
				jlabel.setIcon(ico);
			}

			}
		});
		btn_gq.setText("Start/Question");
		btn_gq.setBounds(354, 129, 124, 25);
		getContentPane().add(btn_gq);

		comboBox = new JComboBox();
		comboBox.setBounds(191, 59, 124, 24);
		getContentPane().add(comboBox);
		comboBox.addItem("China");
		comboBox.addItem("Brazil");
		comboBox.addItem("North Korea");
		comboBox.addItem("South Korea");
		comboBox.addItem("Canada");
		comboBox.addItem("Lithuania");
		comboBox.addItem("US");
		comboBox.addItem("Mongolia");
		comboBox.addItem("Turkey");
		comboBox.addItem("England");

	}


}
